package com.caimiao.miao.page.master.system.lottery;

import com.caimiao.miao.R;
import com.caimiao.miao.interfaces.BaseActivity;
import com.caimiao.miao.library.usb.accessory.UsbAccessoryInterface;
import com.caimiao.miao.library.usb.host.UsbHostInterface;

public class UsbHostActivity extends BaseActivity {
    private UsbHostInterface mUsbHostInterface;
    private UsbAccessoryInterface mUsbAccessoryInterface;
    private boolean isHost;

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_usb_host;
    }

    @Override
    protected void initUI() {
        isHost = true;
    }

    @Override
    protected void initLogic() {
        if (isHost) {
            mUsbHostInterface = new UsbHostInterface(this);
            mUsbHostInterface.getDevices();
        } else {
            mUsbAccessoryInterface = new UsbAccessoryInterface(this);
            mUsbAccessoryInterface.getAccessories();
        }
    }

    @Override
    protected void onDestroy() {
        if (mUsbHostInterface != null) mUsbHostInterface.onDestroy(this);
        if (mUsbAccessoryInterface != null) mUsbAccessoryInterface.onDestroy(this);
        super.onDestroy();
    }
}
